package com.baway.db.dao

import androidx.room.Dao
import androidx.room.Delete
import androidx.room.Insert
import androidx.room.Query
import androidx.room.Update
import com.baway.db.entity.UserInfoEntity

/**
 * Author: Jason Zhang
 * Date: 2025/8/22
 * Desc: 用户信息的操作Dao，提供CRUD操作
 */
@Dao
interface UserInfoDao {

    @Insert
    suspend fun insertUserInfo(vararg user: UserInfoEntity) //vararg表示可以接收多个实体，相当于Java中“...“

    @Delete
    suspend fun deleteUserInfo(vararg user: UserInfoEntity)

    @Update
    suspend fun updateUserInfo(vararg user: UserInfoEntity)

    @Query("select * from user_info where user_id = :userId") //参数必须前面带冒号
    suspend fun queryUserInfoById(userId: Int): UserInfoEntity

    @Query("select * from user_info order by user_id")
    suspend fun queryAllUserInfo(): List<UserInfoEntity>

}